package com.hex.ds.hdrs.app.controller;

import com.hex.ds.hdrs.app.service.impl.AppStatusService;
import com.hex.ds.hdrs.log.po.RunningStateLog;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author lwz
 * @date 2020-12-28
 * @des
 */
@Slf4j
@RestController
@RequestMapping("/api/appStatus")
public class AppStatusController {

    @Autowired
    private AppStatusService appStatusService;

    @GetMapping("/findRunningStateLogByAppCode")
    @ApiOperation("查询运行日志数据")
    public ResponseEntity<Object> findRunningStateLogByAppCode(@RequestParam Integer pageIndex, @RequestParam String appCode) {
        log.info("进入了RunningStateLogController的findRunningStateLogByAppCode方法");
        List<RunningStateLog> list = this.appStatusService.findRunningStateLogByAppCode(pageIndex, appCode);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }

    @PostMapping("/findTaskRunResult")
    @ApiOperation("查询运行日志数据")
    public ResponseEntity<Object> findTaskRunResult(@RequestBody Map paramMap) {
        log.info("进入了RunningStateLogController的findRunningStateLogByAppCode方法,参数: {}", paramMap.toString());
        Map result = this.appStatusService.findTaskRunResult(paramMap);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

    @PostMapping("/findResAndConNum")
    @ApiOperation("查询运行日志数据")
    public ResponseEntity<Object> findResAndConNum(@RequestBody Map paramMap) {
        log.info("进入了RunningStateLogController的findResAndConNum方法,参数: {}", paramMap.toString());
        Map result = this.appStatusService.findResAndConNum(paramMap);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

    @PostMapping("/getTaskBlockNum")
    @ApiOperation("查询阻塞系统数据")
    public ResponseEntity<Object> getTaskBlockNum(@RequestBody Map paramMap) {
        log.info("进入了RunningStateLogController的getTaskBlockNum方法,参数: {}", paramMap.toString());
        Map result = this.appStatusService.getTaskBlockNum(paramMap);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }
}
